﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Skywave
{
    public class ObjectHelper
    {
        public static string ToString(object obj1, bool replaceNull, string nullValue)
        {
            return (obj1 == null && replaceNull) ? nullValue : obj1.ToString();
        }
        public static object CloneUsingSerialization(object serializableObject, Type serializableObjectType)
        {
            object r = null;
            //
            if (serializableObject != null)
            {
                System.Runtime.Serialization.DataContractSerializer serializer1 = new System.Runtime.Serialization.DataContractSerializer(serializableObjectType);
                System.IO.MemoryStream ms1 = new System.IO.MemoryStream();
                serializer1.WriteObject(ms1, serializableObject);
                ms1.Position = 0;
                r = serializer1.ReadObject(ms1);
            }
            //
            return r;
        }
    }
}
